//
//  AdjustViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/24.
//

#import "AdjustViewController.h"
#import "AdjustPageView.h"

@interface AdjustViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate>
@property (nonatomic, strong) JXCategoryTitleView      *categoryView;
@property (nonatomic, strong) JXPagerView *pagingView;
@property(nonatomic,strong) NSMutableArray *listArray;
@end

@implementation AdjustViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"调理";
    
}

- (void)initSubviews {
    [super initSubviews];
    self.listArray = @[].mutableCopy;
    
    self.categoryView = [[JXCategoryTitleView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, kScreenWidth, 44)];
    self.categoryView.delegate = self;
    self.categoryView.titles = @[@"五谷养生",@"中医调理",@"健身运动",@"食疗养生",@"喝茶养生"];
    self.categoryView.titleFont = UIFontMake(14);
    self.categoryView.titleSelectedFont = UIFontMake(14);
    self.categoryView.titleColor = COLOR666;
    self.categoryView.titleSelectedColor = THEME_COLOR;
    self.categoryView.titleColorGradientEnabled = YES;
    self.categoryView.defaultSelectedIndex = 0;
    [self.view addSubview:self.categoryView];
    
    
    JXCategoryIndicatorLineView *line = [[JXCategoryIndicatorLineView alloc] init];
    line.indicatorWidth = 30;
    line.indicatorColor = THEME_COLOR;
    line.lineStyle = JXCategoryIndicatorLineStyle_LengthenOffset;
    self.categoryView.indicators = @[line];
    
    _pagingView = [[JXPagerView alloc] initWithDelegate:self];
    _pagingView.frame = CGRectMake(0, NavigationContentTop + 44, kScreenWidth, kScreenHeight - NavigationContentTop - 44);
    [self.view addSubview:self.pagingView];

    self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;

    self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
    
    
    
    
}

- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
    
}



#pragma mark - JXPagingViewDelegate

- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
    return UIView.new;
}

- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
    return 0;
}

- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
    return 0;
}

- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
    return self.categoryView;
}

- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
    return self.categoryView.titles.count;
}

- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
    AdjustPageView *list = [[AdjustPageView alloc] init];
    return list;
}

- (UIView *)listView{
    return nil;
}
@end
